<?PHP
  class pageselector extends Control{
    public $style       = '';
    public $noValueText = null;
    
    public function getCode(){
      $res =  "<select name=\"".$this->name."\" style=\"".$this->style."\">";
      $pages = $GLOBALS['db']->ReadRows("SELECT * FROM {'dbprefix'}pages ORDER BY title");
      if(isset($this->noValueText)){
        $res .= "<option value=\"-1\">".$this->noValueText."</option>";
      }
      if($pages){
        foreach($pages as $page){
          if($page->id == $this->value){
            $res .= "<option value=\"".$page->id."\" selected=\"1\">".$page->title."</option>";
          }
          else{
            $res .= "<option value=\"".$page->id."\">".$page->title."</option>";
          }
        }
        $res .= "</select>";
        return $res;
      }
    }
  }
?>